home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / c_toolbx.arc / TESTDISP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-03-30  |  2.3 KB  |  95 lines

  1. /* testdisp.c - test viewdisp.c (display_page and disp_char)  */
  2. #include "stdio.h"
  3. #include "cminor.h"
  4. #include "viewparm.h"
  5.  
  6. char filename[81]  ;
  7. char s[256]  ;
  8. extern int row , col  ;
  9. long filesize  ;
  10. long top_of_page  ;
  11. int ix  ;                       /* index to character string  */
  12. int silent  ;                   /* flag for get_next_char  */
  13.  
  14. /* test viewdisp module  */
  15. main()
  16. {
  17.   int c  ;
  18.   char a  ;
  19.   int i  ;
  20.  
  21.   printf("\n testing disp_char")  ;
  22.   while( 1 == 1 )
  23.      {
  24.         printf("\n char (decimal):")  ;
  25.         scanf ("%d",&c)  ;
  26.         if( c == -1 )  break  ;
  27.         printf("\n col:")  ;
  28.         scanf("%d",&col)  ;
  29.         printf("\n row:")  ;
  30.         scanf("%d",&row)  ;
  31.         printf("\n1234567890\n")  ;
  32.  
  33.         for( i=1 ; i < col ; i = i+1 )
  34.            {
  35.               printf(">")  ;
  36.            }
  37.         disp_char(c)  ;
  38.         printf("<  row = %d  col + %d \n",row,col)  ;
  39.      }
  40.  
  41.   printf("\n\n testing display_page \n")  ;
  42.  
  43.   strcpy(filename,"< file name >")  ;
  44.   top_of_page = 333000000 ;
  45.   filesize = 444000000  ;
  46.  
  47.  
  48.   silent = 0  ;
  49.   printf("\n  show get_next_char calls\n")  ;
  50.   display_page()  ;
  51.  
  52.  
  53.   printf("\n test with get_next_char silent\n")  ;
  54.   silent = 1  ;
  55.   printf("\n test with full page-no output from get_next_char\n") ;
  56.   strcpy(s,"1234567890")  ;
  57.   ix = 0  ;
  58.   display_page()  ;
  59.   scanf("%c%c",&a,&a)  ;                /* pause before next test  */
  60.   printf("\n test with EOF in 3rd line-no get_next_char out.\n") ;
  61.   strcpy(s,"1\n2\n\f")  ;
  62.   ix = 0 ;
  63.   display_page()  ;
  64. }
  65.  
  66.  
  67. int get_next_char()
  68. {
  69.   int c  ;
  70.  
  71.   if( silent == 0 )
  72.      {  printf("\n get_next_char called\n") ;
  73.         printf("\n row = %d  col + %d \n",row,col)  ;
  74.         printf("value to return:") ;
  75.         scanf("%d",&c) ;
  76.         return(c) ;
  77.      }
  78.   else if( s[ix] == '\0' )              /* at end of string */
  79.      {  ix = 0  ;                       /* start over in string  */
  80.         return("\n" )  ;                /* and return Newline char */
  81.      }
  82.   else                          /* not at end of string return char  */
  83.      {  c = tochar( s[ix] ) ;
  84.         ix = ix + 1  ;
  85.         if( c == '\f' ) c = EOF_MARK  ;
  86.         return(c)  ;
  87.      }
  88. }
  89.  
  90. int move_to(pos)
  91. long pos ;
  92. {
  93.   printf("\n move to called - position = %1d \n")  ;
  94. }
  95.